import { ref } from "vue";

//取缓存
export const getLocal = (name: any) => {
  return localStorage.getItem(name);
};

//存缓存
export const setLocal = (name: any, value: any) => {
  localStorage.setItem(name, value);
};

// 判断是否是今天
export function isToday(date: string) {
  const d = new Date(date.toString().replace(/-/g, "/"));
  const todaysDate = new Date();
  if (d.setHours(0, 0, 0, 0) == todaysDate.setHours(0, 0, 0, 0)) {
    return true;
  } else {
    return false;
  }
}
// path转Name 去掉/ 首字母大写
export function pathToName(data: string) {
  const fcharac = data.substring(0, 1);
  const str = ref("");
  const newStr = ref("");
  if (fcharac == "/") {
    str.value = data.substring(1, data.length);
  } else {
    str.value = data;
  }
  newStr.value =
    str.value.slice(0, 1).toUpperCase() + str.value.slice(1).toLowerCase();
  return newStr.value;
}
